cargo/new: add `--travis` flag
authorСухарик <suhr@i2pmail.org>
Wed, 3 Sep 2014 15:09:05 +0000 (19:09 +0400)
committerСухарик <suhr@i2pmail.org>
Wed, 3 Sep 2014 15:09:05 +0000 (19:09 +0400)
src/bin/new.rs
src/cargo/ops/cargo_new.rs

index a1e72c1bddab5420762ef5fdc1732e4e0a363de4..bac9739a7b673e9fc180743699308a2011678979 100644 (file)
@@ -15,6 +15,7 @@ Usage:
 Options:
     -h, --help          Print this message
     --git               Initialize a new git repository with a .gitignore
+    --travis            Create a .travis.yml file
     --bin               Use a binary instead of a library template
     -v, --verbose       Use verbose output
 ")
@@ -23,10 +24,11 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>
     debug!("executing; cmd=cargo-new; args={}", os::args());
     shell.set_verbose(options.flag_verbose);
 
-    let Options { flag_git, flag_bin, arg_path, .. } = options;
+    let Options { flag_git, flag_travis, flag_bin, arg_path, .. } = options;
 
     let opts = ops::NewOptions {
         git: flag_git,
+        travis: flag_travis,
         path: arg_path.as_slice(),
         bin: flag_bin,
     };
index 9ff86e79bda7f68990182f39756d5cc235ee40fd..42b631c92ac699c9e5c4833584086da8092fab52 100644 (file)
@@ -8,6 +8,7 @@ use core::shell::MultiShell;
 
 pub struct NewOptions<'a> {
     pub git: bool,
+    pub travis: bool,
     pub bin: bool,
     pub path: &'a str,
 }
@@ -38,6 +39,10 @@ fn mk(path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> {
         try!(fs::mkdir(path, io::UserRWX));
     }
 
+    if opts.travis {
+        try!(File::create(&path.join(".travis.yml")).write_str("language: rust\n"));
+    }
+
     let author = try!(discover_author());
     try!(File::create(&path.join("Cargo.toml")).write_str(format!(
 r#"[package]